package simple;

/**
 * 给出一个 32 位的有符号整数，你需要将这个整数中每位上的数字进行反转。
 * https://leetcode-cn.com/problems/reverse-integer/
 * @author liujianxin
 * @date 2020/7/6 9:20
 */
public class IntReverse {

    public static void main(String[] args) {
        double pow = Math.pow(2.0, 31);
        System.out.println(pow);
    }

    int reverse(int x) {
        boolean negative = false;
        if(x < 0){
            negative = true;
        }
        x = Math.abs(x);
        StringBuilder sb = new StringBuilder(String.valueOf(x));
        try{
            x = Integer.valueOf(sb.reverse().toString());
            return negative ? -x: x;
        }catch (Exception ex){
            return 0;
        }
    }


}
